<?php

declare(strict_types=1);
/**
 * This file is part of Hyperf.
 *
 * @link     https://www.hyperf.io
 * @document https://hyperf.wiki
 * @contact  group@hyperf.io
 * @license  https://github.com/hyperf/hyperf/blob/master/LICENSE
 */

namespace App\Model;


/**
 * @property int $id
 * @property string $name
 * @property string $url
 * @property string $avatar
 * @property string $info
 * @property string $email
 * @property int $sort
 * @property string $reason
 * @property int $status
 * @property string $create_time
 * @property string $update_time
 */
class Friend extends Model
{
    public const CREATED_AT = 'create_time';

    public const UPDATED_AT = 'update_time';

    /**
     * The table associated with the model.
     */
    protected ?string $table = 'friend';

    /**
     * The attributes that are mass assignable.
     */
    // protected array $fillable = [];
    protected array $guarded = [];

    // 如果你需要隐藏原始的 create_time 字段
    protected array $hidden = ['create_time', 'update_time'];

    // 如果你需要显示新的 createTime 字段
    protected array $appends = ['createTime', 'updateTime'];

    /**
     * The attributes that should be cast to native types.
     */
    protected array $casts = ['id' => 'integer', 'sort' => 'integer', 'status' => 'integer'];

    // 获取 createTime 属性
    public function getCreateTimeAttribute()
    {
        return $this->attributes['create_time'];
    }

    public function getUpdateTimeAttribute()
    {
        return $this->attributes['update_time'];
    }
}
